import requests

if __name__ == '__main__':
    headers = {
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.76'
    }
    url = ('https://www.baidu.com/s?wb')
    kw = input('enter a word:')

    param = {
        'wb':'kw'
    }
    reponse = requests.get(url = url,params = param,headers = headers)

    page_text = reponse.text
    fileName = kw+'.text'
    with open(fileName,'w',encoding = 'utf-8') as fp:
        fp.write(page_text)
    print('保存成功')
#UA检测，伪装成某一款浏览器